<?php
namespace app\cms\controller;
use framework\ext\Check;
/* *
 * 网站配置
 * */
class SettingController extends \app\base\controller\AdminController{

    //站点信息
    public function index(){
        $this->config = model('setting')->_select();
        $this->display();  
    } 

    //保存修改
    public function saveconfig(){
        if($this->isPost()){
            $data['title']  = form('post.name');
            $data['content']  = form('post.value');;
            $rel = model('setting')->_update($data,array('title' => $data['title']));
            if($rel){
                echo "修改成功";
            }else{
                echo "修改失败";
            }
        }
    }

    //上传配置
    public function uploads(){
        if($this->isPost()){
            $name  = form('post.name');
            $value = form('post.value');
            switch ($name) {          
                case 'upfolder':
                    $rel = save_config('cms',array('UP_FOLDER'=>$value));
                    break;
                case 'upsize':
                    $rel = save_config('cms', array('UP_SIZE'=>$value));
                    break;
                case 'upexts':
                    $rel = save_config('cms', array('UP_EXTS'=>$value));
                    break;
                case 'ssokey':
                    $rel = save_config('cms', array('SSO_KEY'=>$value));
                    break;                    
                default:
                    $rel = FALSE;
                    break;
            }
            echo "修改成功";
        }else{
            $this->config = config('cms');
            $this->display();
        }
    } 
}